package com.heima.wemedia.controller;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dto.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * 自媒体素材表(WmMaterial)表控制层
 *
 * @author makejava
 * @since 2022-04-10 16:44:05
 */
@RestController
@RequestMapping("/api/v1/material")
@Api(value = "自媒体素材管理",tags = "自媒体")
public class WmMaterialController {

    @Resource
    private WmMaterialService wmMaterialService;

    @PostMapping("upload_picture")
    @ApiOperation("素材上传")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return wmMaterialService.uploadPicture(multipartFile);
    }

    @PostMapping("list")
    @ApiOperation("素材列表查询")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.list(dto);
    }

    @GetMapping("del_picture/{id}")
    @ApiOperation("素材删除")
    public ResponseResult delete(@PathVariable Long id){
        return wmMaterialService.deleteBy(id);
    }

    @GetMapping("collect/{id}")
    @ApiOperation("素材收藏")
    public ResponseResult collect(@PathVariable Long id){
        return wmMaterialService.collect(id);
    }

    @GetMapping("cancel_collect/{id}")
    @ApiOperation("取消收藏")
    public ResponseResult cancelCollect(@PathVariable Long id){
        return wmMaterialService.cancelCollect(id);
    }


}

